<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let user1 = {
            name:'李思',
            key:Symbol('大')
        }
        let user2 = {
            name:'李思',
            key:Symbol('小')
        }
        let grade = {
            [user1.key]:{js:100,css:99},
            [user2.key]:{js:1,css:5}
        }
        console.log(grade[user1.key]);
        console.log(grade[user2.key]);

        let site = Symbol('symbol');
        class User{
            constructor(name){
                this.name = name;
                this[site] = 'admin';
            }
            getName(){
                return this.name + '---' + this[site];
            }
        }
        let p = new User('李思');
        console.log(p.getName());
        for (const key in p) { // 不能循环出 Symbol 定义的属性
            console.log(key)
        }
    </script>
</body>
</html> 